<template>
	<div class="about">
		<el-input v-model="askTitle" placeholder="请输入问题"></el-input>
		<mavon-editor v-model="askContent" ref="md" @change="onTextChange" style="min-height: 400px" />
		<el-divider></el-divider>
		<el-checkbox-group v-model="checkTags" @change="test">
			<el-checkbox v-for="item in checkList" :key="item.id" :label="item.id">{{item.tagName}}</el-checkbox>
		</el-checkbox-group>
		<el-divider></el-divider>
		<el-button type="primary" @click="saveAsk">保存问题</el-button>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				askContent: '',
				askTitle: '',
				askHtml: '',
				checkTags: [],
				checkList: [],
				//defaultData: "preview",
				tableData: [{
					id: '1',
					title: '王小虎上海市普陀区金沙江路',
					address: '上海市普陀区金沙江路 1518 弄'
				}, {
					id: '2',
					title: '王小虎',
					address: '上海市普陀区金沙江路 1517 弄'
				}, {
					id: '3',
					title: '王小虎',
					address: '上海市普陀区金沙江路 1519 弄'
				}, {
					id: '4',
					title: '王小虎',
					address: '上海市普陀区金沙江路 1516 弄'
				}]
			}
		},
		methods: {
			handleEdit(index, row) {
				console.log(index, row);
			},
			handleDelete(index, row) {
				console.log(index, row);
			},
			saveAsk() {
				console.log("aaaaa");
			},
			// 所有操作都会被解析重新渲染
			onTextChange(value, render) {
				// render 为 markdown 解析后的结果[html]
				this.askHtml = render;
			},
			test(){
				console.log(this.checkTags)
			},
			loadTags() {
				let vm = this;
				this.$http.get("/getAllTags")
				.then(function(response){
					//console.log(response);
					vm.checkList = response.data.tags;
				})
				.catch(function(error){
					console.log("请求出错了。。。"+error);
				})
			}
		},
		mounted:function(){
			this.loadTags();
		}
	}
</script>
